package cn.wen.eeayjoke.adapter.home;

import java.util.ArrayList;
import java.util.List;

import cn.wen.base.adapter.recyclerview.QuickRecyclerViewHolder;
import cn.wen.base.adapter.recyclerview.QuickVAdapter;
import cn.wen.base.adapter.viewpager.QuickPagerAdapter;
import cn.wen.base.view.banner.BannerView;
import cn.wen.base.vlayout.layout.LinearLayoutHelper;
import cn.wen.core.banner.BannerCreator;
import cn.wen.eeayjoke.R;
import cn.wen.eeayjoke.banner.QuickBannerCreator;
import cn.wen.eeayjoke.entity.bean.home.AdvBean;
import cn.wen.eeayjoke.entity.bean.home.AdvertisementsBean;
import cn.wen.eeayjoke.utils.ItemTypes;

/**
 * Banner的Adapter
 */

public class BannerAdapter extends QuickVAdapter<AdvertisementsBean> {
    public BannerAdapter(AdvertisementsBean bean, int layoutId) {
        ArrayList<AdvertisementsBean> data = new ArrayList<>();
        data.add(bean);
        LinearLayoutHelper helper = new LinearLayoutHelper();
        // 设置参数
        setData(data);
        setLayoutHelper(helper);
        setLayoutId(layoutId);
    }

    @Override
    protected void convert(QuickRecyclerViewHolder holder, AdvertisementsBean item, int position) {
        BannerView bannerView = holder.getView(R.id.banner_top);
        List<AdvBean> banners = item.items;
        BannerCreator<AdvBean> creator = new QuickBannerCreator();
        QuickPagerAdapter pagerAdapter = new QuickPagerAdapter(banners, creator);
        bannerView.setAdapter(pagerAdapter);
    }

    @Override
    public int getItemViewType(int position) {
        return ItemTypes.TYPE_BANNER;
    }
}
